package com.sk.bilibili.model.activity;

import android.content.Intent;
import android.util.Log;

import com.google.zxing.Result;
import com.mylhyl.zxing.scanner.ScannerOptions;
import com.sk.api.annotations.Autowired;
import com.sk.bilibili.model.BaseModel;
import com.sk.bilibili.other.BiliBiliProperty;
import com.sk.bilibili.utils.DensityUtils;
import com.sk.bilibili.view.activity.ScanActivity;

public class ScanModel extends BaseModel<ScanActivity> {

    @Autowired
    BiliBiliProperty property;

    public ScannerOptions getOptions() {
        return new ScannerOptions.Builder()
                .setFrameSize(200, 200)
                .setTipText("将二维码放入框中")
                .setFrameTopMargin(100)
                .build();
    }

    public Intent handleRes(Result rawResult) {
        String res = rawResult.toString();
        Intent intent = new Intent();
        intent.putExtra("content",res);
        return intent;
    }

    // http://localhost/api/qrCode/generate?info=%E6%B5%8B%E8%AF%95%E4%BF%A1%E6%81%AF
    public String generateUrl(Integer memberId) {
        return String.format("%sqrCode/generate?info=%sspace/%d",
                property.getString("baseUrl"), property.getString("baseFrontUrl"), memberId);
    }

}